package com.wisezone.workflow.dao.ibatis;

import java.util.List;

import com.wisezone.common.dao.impl.BaseDaoImpl;
import com.wisezone.workflow.bean.WfProcessDefinition;
import com.wisezone.workflow.bean.search.WfProcessDefinitionSearch;
import com.wisezone.workflow.dao.WfProcessDefinitionDao;
import com.wisezone.workflow.exception.WfDaoException;

/**
 * IBATIS 流程模版实现类
 * 
 * @author tss 2009-09-05
 * 
 */
public class WfProcessDefinitionDaoImpl extends BaseDaoImpl implements
		WfProcessDefinitionDao {

	public WfProcessDefinitionDaoImpl() {
		super();
	}


	/**
	 * 获得做大版本列表
	 * @return
	 * @throws WfDaoException
	 */
	public List<WfProcessDefinition> getMaxVerList() throws WfDaoException{
		
		WfProcessDefinitionSearch searchEntity = new WfProcessDefinitionSearch();
		return this.listAll("selectMaxVer", searchEntity);
	}
	
	/**
	 * 根据流程标识获得最大版本号
	 * @param key
	 * @return
	 * @throws WfDaoException
	 */
	public Integer getMaxVer(String key) throws WfDaoException{
		
		WfProcessDefinitionSearch searchEntity = new WfProcessDefinitionSearch();
		searchEntity.setKey(key);
		WfProcessDefinition pd = this.get("selectMaxVer", searchEntity);
	    Integer maxVer = 0;
		if(pd != null){
			maxVer = pd.getVersion();
		}
		return maxVer;
	}

}